home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS01.ADF
/
C
/
echox.c
< prev
next >
Wrap
C/C++ Source or Header
|
1985-11-15
|
2KB
|
84 lines
/* expand.doc, echox.c */
#ifdef FOOIE
The file EXPAND.O is the object for a group of subroutines which
expand wild card filenames for AMIGA DOS. The wild card syntax
is similar to unix and implements *, ? and [] type syntax e.g.
*.c /* anything ending in .c */
???.a? /* anything beginning with any three characters,
followed by a . followed by 'a' followed by
any single character */
*.[ch] /* anything ending in .c or .h */
There are two routines:
First:
int iswild(p)
char *p; returns true if the string pointed to by p
contains *, ? or [
Second:
struct args
{
int argcount;
char **argvector;
} *ap,*expand();
struct args *expand(p)
char *p; returns a pointer to a structure as shown above
containing a list of all the matching names.
Note: the names may contain full paths but the
last specifier is file names only. e.g. if
you pass:
a/b/c/* this will work but none of
the directories in c will be found
a/b/*/* does not work!
These routines are available on object form only.
Good luck,
the folks at Tardis Software!
#endif
/* echox.c */
main(argc,argv)
int argc;
char **argv;
{
int i,j;
struct args
{
int argcount;
char **argvector;
} *ap,*expand();
i = 1;
while(--argc)
{
printf("argv[%d] = \"%s\"\n",i,argv[i]);
if (iswild(argv[i]))
{
ap = expand(argv[i]);
printf("ap -> argcount = %d\n",ap -> argcount);
printf("ap -> argvector = %x\n",ap->argvector);
for(j=0; j < ap ->argcount; j++)
printf("argvector[%d]=\"%s\"\n",j,ap->argvector[j]);
}
i++;
}
}